[Pywikipedia-bugs] [Maniphest] [Commented On] T305302: Provide tests for Lexeme classes

2023-02-09 Thread Ayush_Anand3310
Ayush_Anand3310 added a comment.


  is this how it should be?
  
class TestLexemeForm(unittest.TestCase):
def setUp(self):
self.repo = 'test_repo'
self.representations = {'fr': 'example'}
self.claims = {'P21': ['Q8']}
self.grammatical_features = [ItemPage(self.repo, 'Q1'), 
ItemPage(self.repo, 'Q2')]
self.lexeme_form = LexemeForm(repo=self.repo, 
representations=self.representations, 
  claims=self.claims, 
grammatical_features=self.grammatical_features)

def test_toJSON(self):
json_data = self.lexeme_form.toJSON()
self.assertIn('representations', json_data)
self.assertIn('claims', json_data)
self.assertIn('grammaticalFeatures', json_data)

self.assertEqual(json_data['representations'], self.representations)
self.assertEqual(json_data['claims'], self.claims)
self.assertEqual(json_data['grammaticalFeatures'], [feat.getID() 
for feat in self.grammatical_features])

def test_normalizeData(self):
data = {'representations': self.representations, 
'grammaticalFeatures': [feat.getID() for feat in self.grammatical_features]}
normalized_data = self.lexeme_form._normalizeData(data)
self.assertEqual(normalized_data['representations'], 
self.representations)
self.assertEqual(normalized_data['grammaticalFeatures'], 
[feat.getID() for feat in self.grammatical_features])

def test_edit_elements(self):
updated_representations = {'fr': 'new_example'}
updated_claims = {'P21': ['Q9']}
updated_grammatical_features = [ItemPage(self.repo, 'Q3'), 
ItemPage(self.repo, 'Q4')]

data = {'representations': updated_representations, 'claims': 
updated_claims, 'grammaticalFeatures': [feat.getID() for feat in 
updated_grammatical_features]}
self.lexeme_form.edit_elements(data)

data = self.lexeme_form.get()
self.assertEqual(data['representations'], updated_representations)
self.assertEqual(data['claims'], updated_claims)
self.assertEqual([feat.getID() for feat in 
data['grammaticalFeatures']], [feat.getID() for feat in 
updated_grammatical_features])

TASK DETAIL
  https://phabricator.wikimedia.org/T305302

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Ayush_Anand3310
Cc: Ayush_Anand3310, matej_suchanek, Aklapper, Xqt, pywikibot-bugs-list, 
PotsdamLamb, Jyoo1011, JohnsonLee01, SHEKH, Dijkstra, Khutuck, Zkhalido, 
Viztor, Wenyi, Tbscho, MayS, Framawiki, Mdupont, JJMC89, Dvorapa, Altostratus, 
Avicennasis, mys_721tx, jayvdb, Ricordisamoa, Masti, Alchimista
___
pywikibot-bugs mailing list -- pywikibot-bugs@lists.wikimedia.org
To unsubscribe send an email to pywikibot-bugs-le...@lists.wikimedia.org


[Pywikipedia-bugs] [Maniphest] [Commented On] T325883: Test pywikibot with Python 3.10 and Python 3.11

2023-02-09 Thread Aklapper
Aklapper added a comment.


  In T325883#8489003 , 
@RPI2026F1 wrote:
  
  > I noticed that whenever I submit a path the test suite is run from 3.6-3.9.
  
  Please link to an action run URL for this statement :)

TASK DETAIL
  https://phabricator.wikimedia.org/T325883

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Aklapper
Cc: JJMC89, pywikibot-bugs-list, Aklapper, RPI2026F1, PotsdamLamb, Jyoo1011, 
JohnsonLee01, SHEKH, Dijkstra, Khutuck, Zkhalido, Viztor, Wenyi, Tbscho, MayS, 
Framawiki, Mdupont, Dvorapa, Altostratus, Avicennasis, mys_721tx, Xqt, jayvdb, 
Masti, Alchimista
___
pywikibot-bugs mailing list -- pywikibot-bugs@lists.wikimedia.org
To unsubscribe send an email to pywikibot-bugs-le...@lists.wikimedia.org