def test_get_option(self): # arrange expected_option = Option(name="range", feature_name="open", entity_id="gme", option_type="str", value_text="3m") alternate_option = Option(name="range", feature_name="open", entity_id="gme", option_type="str", value_text="3m") MockContext.setup(Option, all=[expected_option, alternate_option], filter=None) # act res = self.client.get(self.base_path + expected_option.name) # assert self.assertEqual(len(res.json), 2) self.assertEqual( res.json, [expected_option.__json__(), alternate_option.__json__()])
def test_get_index(self): # arrange expected_option = Option(name="range", feature_name="open", entity_id="gme", option_type="str", value_text="3m") MockContext.setup(Option, all=[expected_option]) # act res = self.client.get(self.base_path) # assert self.assertEqual(res.status_code, 200) self.assertListEqual(res.json, [expected_option.__json__()])
def test_json(self): # arrange expected_output = { "name": "colour", "entity_id": "F", "feature_name": "make", "option_type": "str", "value": "Black", "value_number": None } option = Option(entity_id="F", feature_name="make", name="colour", option_type="str", value_text="Black") # act json_option = option.__json__() # assert self.assertDictEqual(expected_output, json_option)