def test_save_profile_item(self): filename = 'wallpaper.png' with open(os.path.join('tests', 'support', filename), 'rb') as f: file_contents = f.read() profile_item = ProfileItem() profile_item.type = 'badge' profile_item.name = 'Some item' profile_item.price = 100 expected_file_path = os.path.join('bot', 'images', 'profile_items', 'badges', 'wallpaper.png') result = asyncio.run(Item().save_profile_item(profile_item, filename, file_contents)) self.assertIsNotNone(result) self.assertEqual( Session().query(ProfileItem).filter_by(id=result).count(), 1) self.assertTrue(os.path.exists(expected_file_path)) with open(expected_file_path, 'rb') as f: self.assertEqual(f.read(), file_contents)
def test_validate_type_invalid_type(self): profile_item = ProfileItem() with self.assertRaises(ProfileItemException): profile_item.type = 'invalid'
def test_validate_type_valid_type(self): profile_item = ProfileItem() profile_item.type = 'badge'