Browse Source

rename create_custom_alias -> create_new

Son NK 5 years ago
parent
commit
a3f547fd22
5 changed files with 11 additions and 11 deletions
  1. 3 3
      app/models.py
  2. 3 3
      server.py
  3. 1 1
      tests/api/test_alias_options.py
  4. 3 3
      tests/api/test_new_custom_alias.py
  5. 1 1
      tests/test_models.py

+ 3 - 3
app/models.py

@@ -109,7 +109,7 @@ class User(db.Model, ModelMixin, UserMixin):
         db.session.flush()
 
         # create a first alias mail to show user how to use when they login
-        GenEmail.create_custom_alias(user.id, prefix="my-first-alias")
+        GenEmail.create_new(user.id, prefix="my-first-alias")
         db.session.flush()
 
         return user
@@ -158,7 +158,7 @@ class User(db.Model, ModelMixin, UserMixin):
 
         all_gen_emails = [ge.email for ge in GenEmail.filter_by(user_id=self.id)]
         if self.can_create_new_alias():
-            suggested_gen_email = GenEmail.create_custom_alias(
+            suggested_gen_email = GenEmail.create_new(
                 self.id, prefix=website_name
             ).email
         else:
@@ -393,7 +393,7 @@ class GenEmail(db.Model, ModelMixin):
     user = db.relationship(User)
 
     @classmethod
-    def create_custom_alias(cls, user_id, prefix):
+    def create_new(cls, user_id, prefix):
         if not prefix:
             raise Exception("alias prefix cannot be empty")
 

+ 3 - 3
server.py

@@ -115,9 +115,9 @@ def fake_data():
     api_key = ApiKey.create(user_id=user.id, name="Chrome")
     api_key.code = "code"
 
-    GenEmail.create_custom_alias(user.id, "e1@")
-    GenEmail.create_custom_alias(user.id, "e2@")
-    GenEmail.create_custom_alias(user.id, "e3@")
+    GenEmail.create_new(user.id, "e1@")
+    GenEmail.create_new(user.id, "e2@")
+    GenEmail.create_new(user.id, "e3@")
 
     CustomDomain.create(user_id=user.id, domain="ab.cd", verified=True)
     CustomDomain.create(

+ 1 - 1
tests/api/test_alias_options.py

@@ -39,7 +39,7 @@ def test_different_scenarios(flask_client):
     assert r.json["custom"]["suggestion"] == "test"
 
     # <<< with recommendation >>>
-    alias = GenEmail.create_custom_alias(user.id, prefix="test")
+    alias = GenEmail.create_new(user.id, prefix="test")
     db.session.commit()
     AliasUsedOn.create(gen_email_id=alias.id, hostname="www.test.com")
     db.session.commit()

+ 3 - 3
tests/api/test_new_custom_alias.py

@@ -36,9 +36,9 @@ def test_out_of_quota(flask_client):
     db.session.commit()
 
     # create 3 custom alias to run out of quota
-    GenEmail.create_custom_alias(user.id, prefix="test")
-    GenEmail.create_custom_alias(user.id, prefix="test")
-    GenEmail.create_custom_alias(user.id, prefix="test")
+    GenEmail.create_new(user.id, prefix="test")
+    GenEmail.create_new(user.id, prefix="test")
+    GenEmail.create_new(user.id, prefix="test")
 
     r = flask_client.post(
         url_for("api.new_custom_alias", hostname="www.test.com"),

+ 1 - 1
tests/test_models.py

@@ -27,7 +27,7 @@ def test_suggested_emails_for_user_who_cannot_create_new_email(flask_client):
 
     # make sure user runs out of quota to create new email
     for i in range(MAX_NB_EMAIL_FREE_PLAN):
-        GenEmail.create_custom_alias(user_id=user.id, prefix="test")
+        GenEmail.create_new(user_id=user.id, prefix="test")
     db.session.commit()
 
     suggested_email, other_emails = user.suggested_emails(website_name="test")