def test_random_dates_valid_timerange_only(self):
        """Enforce a valid timerange (start date < end date)"""
        valid_range = get_random_date(self.ten_years_ago, self.today)

        self.assertTrue(valid_range.date())
        self.assertRaises(
            Exception,
            get_random_date,
            self.today,
            self.ten_years_ago,
        )
예제 #2
0
    def run(self):
        subreddit = self.scan_subreddit(self.get_client(), "bitcoin")
        submission = subreddit.random()
        past_date = get_random_date()

        reply_to_comment = self.search_re_in_post_comments(
            submission, r'(\d[.,]*)+[km]*')

        if reply_to_comment:
            print("With USD${} you would've bought: {}".format(
                reply_to_comment["with_number"],
                self.get_price_comparison(reply_to_comment["with_number"])))
            # submission.reply(bot_phrase)
            return
        print("Didn't find numbers")
예제 #3
0
 def test_get_price(self):
     date = get_random_date()
     response = self.pricing.get_price_at_date(date)
     self.assertTrue(type(response["price"]) is float)
예제 #4
0
    def get_price_comparison(self, amount):
        date = get_random_date()
        price = Price().get_price_at_date(date)

        return float(amount) / price["price"]
    def test_random_dates_allow_time_range(self):
        """Allows requesting for a specific time range"""
        date_in_range = get_random_date(self.ten_years_ago, self.today)

        self.assertTrue(date_in_range.date())
    def test_random_dates_two_dates(self):
        """Get a randomdate up to a specific date"""
        date1 = get_random_date(self.ten_years_ago)
        date2 = get_random_date(self.ten_years_ago)

        self.assertFalse(date1.date() == date2.date())