Esempio n. 1
0
    def test_executeBasicRequest(self):
        alert = Alert("final fantasy",
                      [Category("Video Games & Consoles", 1249, 1)])
        executor = EbayFindItemsExecutor(alert)

        executor.execute()

        self.assertIsNotNone(executor.result)
Esempio n. 2
0
    def test_getResultsFromDisk_resultsCorrectlyDeserialized(self):
        alert = Alert("test", [])
        results = self.buildResultsList(10)
        diskIO = ResultsDiskIO()
        filePath = diskIO.saveResultsToDisk(alert, results)

        resultsDeserialized = diskIO.getCurrentResultsFromDisk(alert.uid)
        for resExpected, resActual in zip(results, resultsDeserialized):
            self.compareResults(resExpected, resActual)
Esempio n. 3
0
    def test_saveResultsToDisk_fileCorrectlyCreated(self):
        alert = Alert("test", [])
        results = self.buildResultsList(10)

        diskIO = ResultsDiskIO()
        filePath = diskIO.saveResultsToDisk(alert, results)

        self.assertTrue(os.path.exists(filePath))
        # Test we use the alert's uid in the filename to guarantee its uniqueness.
        self.assertTrue(str(alert.uid) in os.path.basename(filePath))
Esempio n. 4
0
    def test_executeBasicRequest(self):
        alert = Alert("final fantasy",
                      [Category("Video Games & Consoles", 1249, 1)])
        findExecutor = EbayFindItemsExecutor(alert)
        findExecutor.execute()
        self.assertIsNotNone(findExecutor.result)
        result = Result.createFromSerialized(findExecutor.result[0])

        costExecutor = EbayShippingFeesExecutor(result.itemID, "FR")
        costExecutor.execute()
        self.assertIsNotNone(costExecutor.result)
        
 def createAlert(self):
     # TODO : limit category list to 3 ! (it's a limitation of Ebay)
     checkedCategories = self.__getCheckedCategories()
     location = self.locationsComboBox.currentText().split('_')[-1]
     sortOrder = self.sortOrderComboBox.currentText()
     alert = Alert(self.keywordsEdit.text(),
                   checkedCategories,
                   location=location,
                   sortOrder=sortOrder)
     self.keywordsEdit.clear()
     self.alertCreated.emit(alert)
     self.accept()
Esempio n. 6
0
    def __tryCreateAlertFromFile(self, filename, fd):
        uid = uuid.UUID(filename[len(self.alertPrefix):])
        try:
            jsonContent = json.load(fd)
        except:
            print("Invalid alert file format ({})".format(filename))
            return None

        keywords = jsonContent["keywords"]
        categoriesJson = jsonContent["categories"]
        location = jsonContent["location"]
        sortOrder = jsonContent["sortOrder"]
        categoriesList = []
        for categoryJson in categoriesJson:
            category = Category(categoryJson["name"], categoryJson["id"],
                                categoryJson["level"])
            categoriesList.append(category)
        alert = Alert(keywords,
                      categoriesList,
                      location=location,
                      uid=uid,
                      sortOrder=sortOrder)
        return alert
 def __init__(sel):
     super().__init__(
         Alert("final fantasy",
               [Category("Video Games & Consoles", 1249, 1)]))