Skip to content

Commit

Permalink
test: Update test to fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChV committed Sep 24, 2024
1 parent cd75928 commit 7dc6100
Showing 1 changed file with 45 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,26 +348,6 @@ def test_library_blocks(self):
assert problem_get_response.status_code == 200
assert 'You have used 0 of 5 attempts' in problem_get_response.content.decode('utf-8')

# Now verify tags count of the block:
taxonomy = tagging_api.create_taxonomy(name="A", export_id="A")
tagging_api.set_taxonomy_orgs(taxonomy, all_orgs=True)
tagging_api.add_tag_to_taxonomy(taxonomy, "one")
tagging_api.add_tag_to_taxonomy(taxonomy, "two")
tagging_api.tag_object(block_id, taxonomy, ["one", "two"])

new_block_data = self._get_library_block(block_id)
self.assertDictContainsEntries(new_block_data, {
"id": "lb:CL-TEST:téstlꜟط:problem:ࠒröblæm1",
"display_name": "New Multi Choice Question",
"block_type": "problem",
"has_unpublished_changes": True,
"last_published": publish_date.isoformat().replace('+00:00', 'Z'),
"published_by": 'Bob',
"last_draft_created": update_date.isoformat().replace('+00:00', 'Z'),
"last_draft_created_by": None,
'tags_count': 2,
})

# Now delete the block:
assert self._get_library(lib_id)['has_unpublished_deletes'] is False
self._delete_library_block(block_id)
Expand All @@ -383,6 +363,51 @@ def test_library_blocks(self):

# fin

def test_library_block_with_tags(self):
lib = self._create_library(slug="téstlꜟط", title="A Tést Lꜟطrary", description="Tésting XBlocks")
lib_id = lib["id"]
assert lib['has_unpublished_changes'] is False

# A library starts out empty:
assert self._get_library_blocks(lib_id)['results'] == []

# Add a 'problem' XBlock to the library:
create_date = datetime(2024, 6, 6, 6, 6, 6, tzinfo=timezone.utc)
with freeze_time(create_date):
block_data = self._add_block_to_library(lib_id, "problem", "ࠒröblæm1")
self.assertDictContainsEntries(block_data, {
"id": "lb:CL-TEST:téstlꜟط:problem:ࠒröblæm1",
"display_name": "Blank Problem",
"block_type": "problem",
"has_unpublished_changes": True,
"last_published": None,
"published_by": None,
"last_draft_created": create_date.isoformat().replace('+00:00', 'Z'),
"last_draft_created_by": "Bob",
'tags_count': 0,
})
block_id = block_data["id"]

# Now verify tags count of the block:
taxonomy = tagging_api.create_taxonomy(name="A", export_id="A")
tagging_api.set_taxonomy_orgs(taxonomy, all_orgs=True)
tagging_api.add_tag_to_taxonomy(taxonomy, "one")
tagging_api.add_tag_to_taxonomy(taxonomy, "two")
tagging_api.tag_object(block_id, taxonomy, ["one", "two"])

new_block_data = self._get_library_block(block_id)
self.assertDictContainsEntries(new_block_data, {
"id": "lb:CL-TEST:téstlꜟط:problem:ࠒröblæm1",
"display_name": "Blank Problem",
"block_type": "problem",
"has_unpublished_changes": True,
"last_published": None,
"published_by": None,
"last_draft_created": create_date.isoformat().replace('+00:00', 'Z'),
"last_draft_created_by": "Bob",
'tags_count': 2,
})

def test_library_blocks_studio_view(self):
"""
Test the happy path of working with an HTML XBlock in a the studio_view of a content library.
Expand Down

0 comments on commit 7dc6100

Please sign in to comment.