removing DriveAuth step 1 of 2: removing code
authorBryan <btbonval@gmail.com>
Sat, 21 Dec 2013 00:02:42 +0000 (19:02 -0500)
committerBryan <btbonval@gmail.com>
Sat, 21 Dec 2013 00:02:42 +0000 (19:02 -0500)
karmaworld/apps/document_upload/tests.py
karmaworld/apps/notes/admin.py
karmaworld/apps/notes/models.py
karmaworld/apps/notes/tests.py

index 0beba9f766405ca48d1b49df3eb8c733f0d2e8d2..cb4d13e630d873a4284104e9b64ed1861974567e 100644 (file)
@@ -27,16 +27,6 @@ class ConversionTest(TestCase):
         self.course = Course(name='Intro to Advanced Study', school=self.school)
         self.course.save()
         self.client = Client()
-        self.setUpGDriveAuth()
-
-    def setUpGDriveAuth(self):
-        try:
-            f = open(CREDENTIALS_PATH)
-        except IOError:
-            raise RuntimeError("Could not find {c}, did you create it? See docs/source/gdrive.rst".format(c=CREDENTIALS_PATH))
-        creds_str = f.read()
-        f.close()
-        DriveAuth(credentials=creds_str).save()
 
     def doConversionForPost(self, post):
         self.assertEqual(Note.objects.count(), 0)
index 91eab81068fd426a195718d7148ebd5dd63e1db3..ff4c6ee558340ec1e1f20e4b35561ac5c3710f5c 100644 (file)
@@ -5,7 +5,6 @@
 
 from django.contrib import admin
 
-from karmaworld.apps.notes.models import DriveAuth
 from karmaworld.apps.notes.models import Note
 
 class NoteAdmin(admin.ModelAdmin):
@@ -16,5 +15,4 @@ class NoteAdmin(admin.ModelAdmin):
         'fk': ['course']
     }
 
-admin.site.register(DriveAuth)
 admin.site.register(Note, NoteAdmin)
index 342defd2117d0f5b3f7c6174ebeb49b2ccbf4f2a..b56e7191b03f77bfe052f42780751d2fa7853763 100644 (file)
@@ -233,36 +233,3 @@ def note_receiver(sender, **kwargs):
 @receiver(post_delete, sender=Note, weak=False)
 def note_receiver(sender, **kwargs):
     update_note_counts(kwargs['instance'])
-
-
-class DriveAuth(models.Model):
-    """ stored google drive authentication and refresh token
-        used for interacting with google drive """
-
-    email = models.EmailField(default=GOOGLE_USER)
-    credentials = models.TextField() # JSON of Oauth2Credential object
-    stored_at = models.DateTimeField(auto_now=True)
-
-
-    @staticmethod
-    def get(email=GOOGLE_USER):
-        """ Staticmethod for getting the singleton DriveAuth object """
-        # FIXME: this is untested
-        return DriveAuth.objects.filter(email=email).reverse()[0]
-
-
-    def store(self, creds):
-        """ Transform an existing credentials object to a db serialized """
-        self.email = creds.id_token['email']
-        self.credentials = creds.to_json()
-        self.save()
-
-
-    def transform_to_cred(self):
-        """ take stored credentials and produce a Credentials object """
-        return Credentials.new_from_json(self.credentials)
-
-
-    def __unicode__(self):
-        return u'Gdrive auth for %s created/updated at %s' % \
-                    (self.email, self.stored_at)
index e2b5bc953b237ba9fe90dd32d654ef96b813c25e..0425f438b219b655e51f8dfda613b4540e0a5964 100644 (file)
@@ -11,7 +11,6 @@ from nose.tools import ok_
 from nose.tools import assert_is_none
 
 from karmaworld.apps.notes.models import Note
-from karmaworld.apps.notes.models import DriveAuth
 from karmaworld.apps.courses.models import Course
 from karmaworld.apps.courses.models import School
 
@@ -103,48 +102,3 @@ class TestNoteUrl(BaseNote):
         self.note.slug = None
         url = self.expected_url_prefix + str(self.note.id)
         eq_(self.note.get_absolute_url(), url)
-
-
-class BaseDriveAuth(object):
-    google_user = u'foobie@blet.ch'
-    json_str = """
-    {"_module": "oauth2client.client", "_class": "OAuth2Credentials", "access_token": "asdfasdfasdfasdfasdfasdfasdf", "token_uri": "https://accounts.google.com/o/oauth2/token", "invalid": false, "client_id": "9999999999999.apps.googleusercontent.com", "id_token": {"aud": "9999999999999.apps.googleusercontent.com", "cid": "9999999999999.apps.googleusercontent.com", "iss": "accounts.google.com", "email": "foobie@blet.ch", "exp": 1354832924, "iat": 1354829024, "token_hash": "xXxXxXyyYyYyYyYyYy", "id": "444444444444444444444", "hd": "karmanotes.org", "verified_email": "true"}, "client_secret": "7&7&&7&7&7&7&&&&&&&&&&&(", "token_expiry": "2013-02-04T23:46:47Z", "refresh_token": "qweasdzxcrtyfghvbnuiojklm,.", "user_agent": null}
-    """
-
-    def setup(self):
-        self.drive_auth = DriveAuth()
-        self.drive_auth.email = self.google_user
-        self.drive_auth.credentials = self.json_str
-        self.drive_auth.save()
-
-    def teardown(self):
-        self.drive_auth.delete()
-
-
-
-class MockCred(object):
-    id_token = {'email': u'Mock@email.me'}
-
-    def to_json(self):
-        return "Yo, this is the json you wanted, not really"
-
-
-class TestDriveAuth(BaseDriveAuth):
-
-    def test_drive_auth_get(self):
-        """ Test getting via DriveAuth.get() staticmethod """
-        drive_auth = DriveAuth.get(email=self.google_user)
-        eq_(drive_auth, self.drive_auth)
-
-class TestDriveAuthStore(BaseDriveAuth):
-
-    def test_drive_auth_store(self):
-        cred = MockCred() # create a mock credentials object
-        self.drive_auth.store(cred) # use that to override the drive auth object
-        # The drive auth email should have been reset based on the MockCred value
-        ok_(self.drive_auth.email != self.google_user, 
-            "DriveAuth.email should have been reset based on the MockCred \
-            passed to DriveAuth.store()")
-        eq_(self.drive_auth.email, u'Mock@email.me')
-
-