def test_get_score_sheet_if_not_present_in_db_and_fetch( self, mock_client_call): expected = test_score_encoding.get_sample() mock_client_call.return_value = expected.encode("utf-8") document = score_encoding.get_score_sheet("12012") self.assertJSONEqual(document, expected, "Should fetch document from queue")
def test_get_score_sheet_if_not_present_in_db_with_timeout( self, mock_client_call): mock_client_call.return_value = None document = score_encoding.get_score_sheet("12012") self.assertIsNone( document, "Should timeout when waiting for document and return none")
def test_get_score_sheet_if_present_in_db_but_outdated(self, mock_client_call): global_id = "12012" new_score_encoding = test_score_encoding.create_score_encoding(global_id=global_id) new_score_encoding.document = test_score_encoding.get_old_sample() new_score_encoding.save() expected = test_score_encoding.get_sample() mock_client_call.return_value = expected.encode("utf-8") document = score_encoding.get_score_sheet(global_id) self.assertJSONEqual(document, expected, "Should fetch document from queue")
def test_get_score_sheet_if_present_in_db_but_outdated( self, mock_client_call): global_id = "12012" new_score_encoding = test_score_encoding.create_score_encoding( global_id=global_id) new_score_encoding.document = test_score_encoding.get_old_sample() new_score_encoding.save() expected = test_score_encoding.get_sample() mock_client_call.return_value = expected.encode("utf-8") document = score_encoding.get_score_sheet(global_id) self.assertJSONEqual(document, expected, "Should fetch document from queue")
def test_get_score_sheet_if_present_in_db(self): document = score_encoding.get_score_sheet(self.global_id) self.assertJSONEqual(self.score_encoding.document, document, "Should return the document in db")
def test_get_score_sheet_if_not_present_in_db_and_fetch(self, mock_client_call): expected = test_score_encoding.get_sample() mock_client_call.return_value = expected.encode("utf-8") document = score_encoding.get_score_sheet("12012") self.assertJSONEqual(document, expected, "Should fetch document from queue")
def test_get_score_sheet_if_not_present_in_db_with_timeout(self, mock_client_call): mock_client_call.return_value = None document = score_encoding.get_score_sheet("12012") self.assertIsNone(document, "Should timeout when waiting for document and return none")
def test_get_score_sheet_if_present_in_db(self): document = score_encoding.get_score_sheet(self.global_id) self.assertJSONEqual(self.score_encoding.document, document, "Should return the document in db")